﻿<navigation:Page x:Class="GraphMyCode.Client.Views.GraphMapPage"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 mc:Ignorable="d"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:Controls="clr-namespace:GraphMyCode.Client.Controls"
                 xmlns:GraphControlLibrary="clr-namespace:GraphMyCode.Controls;assembly=GraphMyCode.Controls"
                 Title="Code Graph">
    <Grid x:Name="LayoutRoot">

        <Border Style="{StaticResource paneBorder}"
                HorizontalAlignment="Left"
                BorderThickness="0"
                VerticalAlignment="Top"
                x:Name="zoomBorder"
                Opacity=".2"
                MouseEnter="zoomBorder_MouseEnter"
                MouseLeave="zoomBorder_MouseLeave">
            <Border.Resources>
                <Storyboard x:Key="showZoom">
                    <DoubleAnimation Storyboard.TargetName="zoomBorder"
                                     Storyboard.TargetProperty="Opacity"
                                     To="1" />
                </Storyboard>
                <Storyboard x:Key="hideZoom">
                    <DoubleAnimation Storyboard.TargetName="zoomBorder"
                                     Storyboard.TargetProperty="Opacity"
                                     To="0.2" />
                </Storyboard>
            </Border.Resources>
            <Controls:ZoomBox x:Name="zoomBox"
                              Value="{Binding ZoomPercentage, Mode=TwoWay}" />
        </Border>

        <StackPanel Canvas.ZIndex="2"
                    VerticalAlignment="Top"
                    HorizontalAlignment="Right"
                    Margin="10"                     
                    Orientation="Horizontal">
            <Button x:Name="ResetButton"
                    Style="{StaticResource GlassButton}"
                    Click="ResetZoomButton_Click"
                    Content="100%">
                <ToolTipService.ToolTip>
                    <ToolTip Content="100% zoom"
                             Placement="Right" />
                </ToolTipService.ToolTip>
            </Button>

            <Button x:Name="FullScreenButton"
                    Style="{StaticResource GlassButton}"
                    Click="FullScreenButton_Click"
                    Content="Full Screen">
                <ToolTipService.ToolTip>
                    <ToolTip Content="Full screen"
                             Placement="Right" />
                </ToolTipService.ToolTip>
            </Button>

            <Button x:Name="ToolButton"
                    Style="{StaticResource GlassButton}"
                    Click="ToolButton_Click"
                    Content="Pan">
                <ToolTipService.ToolTip>
                    <ToolTip Content="Pan tool"
                             Placement="Right" />
                </ToolTipService.ToolTip>
            </Button>

            <StackPanel>
                <Controls:SearchBox Width="200"
                                    x:Name="searchTextBox"
                                    Margin="4"
                                    Background="#33DDDDDD"
                                    Foreground="White"
                                    BorderBrush="White"
                                    SelectedItem="{Binding SearchText, Mode=TwoWay}"
                                    IsTextCompletionEnabled="False"
                                    ItemsSource="{Binding AllNodesText, Mode=OneWay}"
                                    FilterMode="Contains" />
            </StackPanel>
        </StackPanel>

        <StackPanel Canvas.ZIndex="0"
                    VerticalAlignment="Top"
                    HorizontalAlignment="Center">
            <TextBlock Text="{Binding Metadata.Title}"
                       FontSize="30"
                       Margin="0,10,5,0"
                       Foreground="DarkGray"
                       Opacity=".7" />

            <TextBlock Text="{Binding Metadata.Description}"
                       HorizontalAlignment="Center"
                       FontSize="30"
                       Foreground="DarkGray"
                       Opacity=".7" />
        </StackPanel>

        <GraphControlLibrary:GraphControl x:Name="graphControl"
                                          SearchText="{Binding SearchText}"
                                          SearchProperty="Text"
                                          ZoomPercentage="{Binding ZoomPercentage, Mode=TwoWay}"
                                          IsZoomReset="{Binding IsZoomReset, Mode=TwoWay}"
                                          IsDraggingSpaceEnabled="{Binding IsDraggingEnabled}"                                          
                                          ItemsSource="{Binding Graph.Elements}">
            <GraphControlLibrary:GraphControl.ItemTemplate>
                <DataTemplate>
                    <Grid x:Name="InnerPanel">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Path Data="{Binding ShapeGeometry}"
                              Stroke="{Binding Color}"
                              StrokeThickness="2" />
                        <Image Source="{Binding ImageName}"
                               Height="{Binding Width}"
                               VerticalAlignment="Top"
                               Width="{Binding Width}"
                               Stretch="Uniform" />
                        <!--<Path x:Name="path"
                                  Data="{Binding ShapeGeometry}">
                                <Path.Fill>
                                    <ImageBrush Stretch="UniformToFill"
                                                ImageSource="{Binding ImageName}" />
                                </Path.Fill>
                                <Path.Effect>
                                    <DropShadowEffect Color="Red"
                                                      Direction="0"
                                                      BlurRadius="10"
                                                      Opacity="1"
                                                      ShadowDepth="0" />
                                </Path.Effect>
                            </Path>-->
                        <HyperlinkButton Click="HyperlinkButton_Click"
                                         VerticalAlignment="Center"
                                         Grid.Column="1"
                                         Content="{Binding Text}"
                                         FontSize="{Binding FontSize}"
                                         FontStyle="Italic">
                            <!--<TextBlock Text="{Binding Text}"
                                           FontSize="{Binding FontSize}"
                                           FontStyle="Italic"
                                           TextWrapping="Wrap" />-->
                        </HyperlinkButton>
                        <ToolTipService.ToolTip>
                            <ToolTip Background="WhiteSmoke">
                                <ItemsControl ItemsSource="{Binding VisibleAttributes}">
                                    <ItemsControl.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <TextBlock Text="{Binding Key}"
                                                           FontWeight="Bold"
                                                           Margin="2,2,0,2"
                                                           VerticalAlignment="Top" />
                                                <TextBlock Text=": "
                                                           FontWeight="Bold"
                                                           Margin="0,2"
                                                           VerticalAlignment="Top" />
                                                <TextBlock Text="{Binding Value}"
                                                           Margin="0,2,2,2"
                                                           VerticalAlignment="Top" />
                                            </StackPanel>
                                        </DataTemplate>
                                    </ItemsControl.ItemTemplate>
                                </ItemsControl>
                            </ToolTip>
                        </ToolTipService.ToolTip>
                    </Grid>
                </DataTemplate>
            </GraphControlLibrary:GraphControl.ItemTemplate>
        </GraphControlLibrary:GraphControl>

        <!--<Border Style="{StaticResource paneBorder}"
                HorizontalAlignment="Left"
                VerticalAlignment="Bottom"
                Background="WhiteSmoke"
                Opacity=".7">
            <ItemsControl ItemsSource="{Binding Legend.Items}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Grid Margin="2">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Path Data="{Binding ShapeGeometry, Mode=OneTime}"
                                  Fill="{Binding Color, Mode=OneTime}"
                                  Stroke="Black"
                                  StrokeThickness="1"
                                  Grid.Column="0"
                                  VerticalAlignment="Center" />
                            <TextBlock Margin="2,0,0,0"
                                       VerticalAlignment="Center"
                                       Grid.Column="1"
                                       Text="{Binding Text}" />
                        </Grid>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Border>-->
    </Grid>
</navigation:Page>
